package com.wjw.java.oop.extends_.demo;

/**
 * 大学生,子类
 * 继承父类Student
 */
public class Graduate extends Student {
    //子类特有的属性
    private String hobby;

    public String getHobby() {
        return this.hobby;
    }

    public void setHobby(String hobby) {
        this.hobby = hobby;
    }

    public Graduate() {
        //super();//默认调用父类的无参构造,哪怕没有写
        System.out.println("Graduate子类：无参构造");
    }

    public Graduate(String name, int age, int score, String hobby) {
        super(name, age, score);//调用父类的有参构造
        this.hobby = hobby;
        System.out.println("Graduate子类：有参构造！！！");
    }

    //子类特有的方法
    public void myHobby(){
        System.out.println("大学生喜欢："+this.hobby);
    }
}
